let fs = require("fs");

// 创建一个可读流
let rs = fs.createReadStream("hello3.txt");
// 创建一个可写流
let ws = fs.createWriteStream("hello5.txt");

// 监听流的打开和关闭
rs.once("open", () => {
    console.log("可读流已打开");
});
rs.once("close", () => {
    console.log("可读流已关闭");
});
ws.once("open", () => {
    console.log("可写流已打开");
});
ws.once("close", () => {
    console.log("可写流已关闭");
});

// pipe()可以将可读流中的内容直接输出到可写流中
rs.pipe(ws);
